import Vue from 'vue'
import vueRouter from 'vue-router'
import Home from '@/pages/home/Home'  //@代表src路径
import City from '@/pages/city/City'
import Detail from '@/pages/detail/Detail'


Vue.use(vueRouter)  //Vue全局使用router 上面从vue-router导入的vueRouter

export default new vueRouter({                                                 //理解这一句： 
  routes: [                         //routes是一个数组  route是一个单的对象     const routes=[...]
    {                                                                     //  var router=new vueRouter({
      path: '/',                                                          //      routes})
      name: 'Home',                                                       //  export defalut router;
      component:Home
    },
    {                                                                    
      path: '/city',                                                          
      name: 'City',                                                       
      component:City
    },
    {
      path: '/detail/:id',       //:id 动态路由                                                   
      name: 'Detail',                                                       
      component:Detail
    }
  ],
  scrollBehavior (to, from, savedPosition) {
    return {x:0,y:0}
  }  //让每次切换路由导航后页面滚到顶部
})
